<template>
  <div class="backend">
    <!-- 菜单导航区 -->
    <div class="menu">
      <a-menu
        :style="{ width: '200px', height: '100%' }"
        :default-open-keys="['0']"
        :default-selected-keys="['0_2']"
        show-collapse-button
        breakpoint="xl"
        @menu-item-click="menuItemClickHandler"
      >
        <a-sub-menu key="0">
          <template #icon><icon-book /></template>
          <template #title>文章管理</template>
          <a-menu-item key="/backend/blog">文章列表</a-menu-item>
          <a-menu-item key="/backend/tag">标签列表</a-menu-item>
        </a-sub-menu>
        <a-sub-menu key="1">
          <template #icon><icon-palette /></template>
          <template #title>评论管理</template>
          <a-menu-item key="/backend/comment">评论列表</a-menu-item>
        </a-sub-menu>
      </a-menu>
    </div>
    <!-- 内容操作区 -->
    <div class="main">
      <!-- 子路由的视图, 前提是TestView的视图和TestView2的视图的有路由是路由是嵌套的 -->
      <router-view></router-view>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'

const router = useRouter()

const menuItemClickHandler = (key) => {
  router.push(key)
}
</script>

<style lang="css" scoped>
.backend {
  display: flex;
  height: calc(100vh - 47px);
}

.menu {
  border-right: 2px solid rgb(229,230,235);
}

.main {
  padding: 8px;
  width: 100%;
}
</style>
